package com.aaa.demo05;

/**
 * @author ${崔灿}
 * @date 2022/11/01 15:39
 **/

public class TestJoin {
    public static void main(String[] args) throws InterruptedException {
        JoinDemo t1 = new JoinDemo();
        t1.start();
        JoinDemo t2 = new JoinDemo();
        t2.start();

        //main允许t1下加入，只有t1线程执行完毕后主线程才会执行
        t1.join();
        t2.join();
        for (int i = 0; i < 20 ; i++   ) {
            System.out.println("main******"+i);
}
    }
}
class JoinDemo extends Thread{
    @Override
    public void run() {
        for (int i = 0; i <20; i++){
            System.out.println(Thread.currentThread().getName() + "****"+i);
        }
    }
}